package ru.usu.gv.utils;

import java.util.ArrayList;
import java.util.List;

import javax.swing.filechooser.FileFilter;

/**
 @author Sergey Pupyrev 
 05.05.2007
 */

public class Files
{
    public static class GraphMLFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return (file.isDirectory() || file.getName().endsWith(".gml"));
        }

        @Override
        public String getDescription()
        {
            return "GraphML file (.gml)";
        }
    }

    public static class HTMLFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".html");
        }

        @Override
        public String getDescription()
        {
            return "HTML Image (.html)";
        }
    }

    public static class PNGFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".png");
        }

        @Override
        public String getDescription()
        {
            return "Standard PNG Image writer (.png)";
        }
    }

    public static class JPEGFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".jpg");
        }

        @Override
        public String getDescription()
        {
            return "JPEG Image Files (.jpg)";
        }
    }

    public static class SVGFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".svg");
        }

        @Override
        public String getDescription()
        {
            return "SVG (*.svg)";
        }
    }

    public static class BMPFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".bmp");
        }

        @Override
        public String getDescription()
        {
            return "Standard BMP Image writer (.bmp)";
        }
    }

    public static class PDFFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".pdf");
        }

        @Override
        public String getDescription()
        {
            return "PDF Format (.pdf)";
        }
    }

    public static class AVIFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".avi");
        }

        @Override
        public String getDescription()
        {
            return "AVI Format (.avi)";
        }
    }

    public static class LJFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".lj");
        }

        @Override
        public String getDescription()
        {
            return "LJ Format (.lj)";
        }
    }

    public static class DotFileFilter extends FileFilter
    {
        @Override
        public boolean accept(java.io.File file)
        {
            return file.isDirectory() || file.getName().endsWith(".dot");
        }

        @Override
        public String getDescription()
        {
            return ".dot";
        }
    }

    public static FileFilter getFileFilter()
    {
        return new GraphMLFileFilter();
    }

    public static List<FileFilter> listExportFileFilters()
    {
        List<FileFilter> result = new ArrayList<FileFilter>();
        result.add(new JPEGFileFilter());
        result.add(new BMPFileFilter());
        result.add(new HTMLFileFilter());
        result.add(new PDFFileFilter());
        result.add(new AVIFileFilter());
        result.add(new LJFileFilter());
        result.add(new DotFileFilter());
        result.add(new PNGFileFilter());
        result.add(new SVGFileFilter());

        return result;
    }
}
